home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / xview / genial / lib / backup / lib_test.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-14  |  1.3 KB  |  58 lines

  1.  
  2. /* test_lib.c   to test c_array lib calls
  3.  */
  4.  
  5. #include <hipl_format.h>
  6. #include <stdio.h>
  7. #include <sys/types.h>
  8.  
  9. char     *Progname;
  10.  
  11.  
  12. main(argc, argv)
  13.     int       argc;
  14.     char     *argv[];
  15. {
  16.     register int i, j, k, check;
  17.     struct header hd;
  18.     u_char **alloc_2d_byte_array();
  19.     u_char ***alloc_3d_byte_array(); 
  20.  
  21.     u_char ***pic_3d;
  22.     u_char  **pic_2d;
  23.  
  24.     Progname = strsave(*argv);
  25.  
  26.     read_header(&hd);
  27.     if (hd.pixel_format != PFBYTE)
  28.     perr("image pixel format must be byte");
  29.     update_header(&hd, argc, argv);
  30.     write_header(&hd);
  31.  
  32.     if (hd.num_frame == 1) {
  33.     pic_2d = alloc_2d_byte_array(hd.cols, hd.rows);
  34.     read_2d_byte_array(stdin, pic_2d, hd.cols, hd.rows);
  35.     
  36.     for (j = 0; j < hd.cols; j++)
  37.         for (k = 0; k < hd.rows; k++) 
  38.             ;      /* do stuff here */
  39.  
  40.     write_2d_byte_array(stdout, pic_2d, hd.cols, hd.rows);
  41.     free_2d_byte_array(pic_2d);
  42.  
  43.   /* 3D test */
  44.     } else {
  45.     pic_3d = alloc_3d_byte_array( hd.cols, hd.rows, hd.num_frame);
  46.     read_3d_byte_array(stdin, pic_3d, hd.cols, hd.rows, hd.num_frame);
  47.     for (i = 0; i < hd.cols; i++)
  48.         for (j = 0; j < hd.rows; j++)
  49.         for (k = 0; k < hd.num_frame; k++) 
  50.              check = pic_3d[i][j][k];
  51.  
  52.     write_3d_byte_array(stdout, pic_3d, hd.cols, hd.rows, hd.num_frame);
  53.     free_3d_byte_array(pic_3d);
  54.     }
  55.     return (0);
  56. }
  57.  
  58.